<h1>Listing suppliers</h1>

<table>
  <tr>
  <% for column in Supplier.content_columns %>
    <th><%= column.human_name %></th>
  <% end %>
  <% if logged_in? -%>
  <th>New orders</th>
  <% end -%>
    <th colspan=3>Action</th>
  </tr>
  
<% for supplier in @suppliers %>
  <tr>
  <% for column in Supplier.content_columns %>
    <td><%=h supplier.send(column.name) %></td>
  <% end %>
  <% if logged_in? -%>
    <% if !watched?(supplier) -%>
      <td> <%= link_to 'Watch', { :action => 'watch', :id => supplier }, :method => :post %></td>
    <% else -%>
      <td> <%= link_to 'Ignore', { :action => 'ignore', :id => supplier }, :method => :post %></td>
     <% end -%> 
    <% end -%>
   <td><%= link_to 'Show', :action => 'show', :id => supplier %></td>
    <td><%= link_to 'Edit', :action => 'edit', :id => supplier %></td>
    <td><%= link_to 'Destroy', { :action => 'destroy', :id => supplier }, :confirm => 'Are you sure?', :method => :post %></td>
  </tr>
<% end %>
</table>

<%= link_to 'Previous page', { :page => @supplier_pages.current.previous } if @supplier_pages.current.previous %>
<%= link_to 'Next page', { :page => @supplier_pages.current.next } if @supplier_pages.current.next %> 

<br />

<%= link_to 'New supplier', :action => 'new' %>
